{extend name="base" /}
{block name="css"}
<style type="text/css">
        body, html{width: 100%;height: 100%;overflow: hidden;margin:0;}
        #allmap {width:600px;height:300px;overflow: hidden;}

        dl,dt,dd,ul,li{
            margin:0;
            padding:0;
            list-style:none;
        }
        p{font-size:12px;}
        dt{
            font-size:14px;
            font-family:"微软雅黑";
            font-weight:bold;
            border-bottom:1px dotted #000;
            padding:5px 0 5px 5px;
            margin:5px 0;
        }
        dd{
            padding:5px 0 0 5px;
        }
        li{
            line-height:28px;
        }
    </style>
{/block}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                    <input type="text" name="username" value="{$data.username|default=''}" autocomplete="off" placeholder="请输入用户名" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">员工姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="realname" value="{$data.realname|default=''}" autocomplete="off" placeholder="请输入昵称" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-inline">
                    <input type="text" name="mobile" value="{$data.mobile|default=''}" autocomplete="off" placeholder="请输入手机号" lay-verify="phone|number" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" value="" autocomplete="off" placeholder="请输入密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色</label>
                <div class="layui-input-inline">
                    <select name="group_id">
                        <option value="">请选择角色</option>
                        {foreach name="userAuthGroup" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.group_id eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=3ac1342b68fec1069cd54e9af77f7b05"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map('map');
    //以钦州初始化城市...
    map.centerAndZoom("南宁",15);
    map.enableScrollWheelZoom();
    var overlays = [];
    //回调获得覆盖物信息
    var overlaycomplete = function(e){
        clearbefore();
        overlays.push(e.overlay);
        var result="";
        if (e.drawingMode == BMAP_DRAWING_MARKER) {
            $("#map_x").find('input').val(e.overlay.getPosition().lng);
            $("#map_y").find('input').val(e.overlay.getPosition().lat);
            result += ' 坐标：' + e.overlay.getPosition().lng + ',' + e.overlay.getPosition().lat;
        }
        console.log(result)
    };
    //实例化鼠标绘制工具
    var drawingManager = new BMapLib.DrawingManager(map, {
        isOpen: true, //是否开启绘制模式
        enableDrawingTool: false,
        setDrawingMode:BMAP_DRAWING_MARKER//画点
    });

    //添加鼠标绘制工具监听事件，用于获取绘制结果
    drawingManager.addEventListener('overlaycomplete', overlaycomplete);
    function clearbefore() {
        for(var i = 0; i < overlays.length; i++){
            map.removeOverlay(overlays[i]);
        }
    }
</script>
{/block}